/*
 Navicat Premium Dump SQL

 Source Server         : flink_cluster_monitor
 Source Server Type    : MySQL
 Source Server Version : 80024 (8.0.24)
 Source Host           : 10.1.1.26:3306
 Source Schema         : flink_cluster_monitor

 Target Server Type    : MySQL
 Target Server Version : 80024 (8.0.24)
 File Encoding         : 65001

 Date: 23/10/2025 12:51:45
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for callback_data
-- ----------------------------
DROP TABLE IF EXISTS `callback_data`;
CREATE TABLE `callback_data` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `receive_time` varchar(50) NOT NULL COMMENT '接收时间',
  `receive_seq` int NOT NULL COMMENT '接收序号',
  `data_json` longtext NOT NULL COMMENT 'JSON数据',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `idx_receive_seq` (`receive_seq`),
  KEY `idx_receive_time` (`receive_time`),
  KEY `idx_created_at` (`created_at`)
) ENGINE=InnoDB AUTO_INCREMENT=467 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='回调数据表';

-- ----------------------------
-- Table structure for callback_service_status
-- ----------------------------
DROP TABLE IF EXISTS `callback_service_status`;
CREATE TABLE `callback_service_status` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `service_name` varchar(100) NOT NULL DEFAULT 'default' COMMENT '服务名称',
  `running` tinyint(1) NOT NULL DEFAULT '1' COMMENT '运行状态',
  `start_time` timestamp NULL DEFAULT NULL COMMENT '启动时间',
  `total_received` int NOT NULL DEFAULT '0' COMMENT '总接收数量',
  `last_receive_time` varchar(50) DEFAULT NULL COMMENT '最后接收时间',
  `storage_mode` varchar(20) NOT NULL DEFAULT 'file' COMMENT '存储模式',
  `config_json` json DEFAULT NULL COMMENT '配置信息',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_service_name` (`service_name`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='回调服务状态表';

-- ----------------------------
-- Table structure for flink_cluster_alert_history
-- ----------------------------
DROP TABLE IF EXISTS `flink_cluster_alert_history`;
CREATE TABLE `flink_cluster_alert_history` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键，自增ID',
  `alert_id` varchar(128) DEFAULT NULL COMMENT 'Alertmanager告警唯一标识',
  `group_key` varchar(256) DEFAULT NULL COMMENT '告警分组键',
  `job_id` varchar(64) DEFAULT NULL COMMENT 'Flink作业ID(可为空)',
  `job_name` varchar(255) DEFAULT NULL COMMENT 'Flink作业名称(可为空)',
  --`alert_type` enum('FIRST_FAILURE','RETRY_FAILURE','FINAL_FAILURE','RECOVERED','OTHER','FIRING','RESOLVED','ALERTMANAGER') NOT NULL COMMENT '告警类型',
  `alert_type` varchar(255) NOT NULL COMMENT '告警类型',
  `alert_title` varchar(255) NOT NULL COMMENT '告警标题',
  `alertname` varchar(255) DEFAULT NULL COMMENT '告警名称(兼容Alertmanager)',
  `instance` varchar(255) DEFAULT NULL COMMENT '实例地址',
  `severity` enum('emergency','critical','exception','warning','info') DEFAULT 'warning' COMMENT '告警级别',
  `hostname` varchar(64) DEFAULT NULL COMMENT '主机名',
  `service` varchar(64) DEFAULT NULL COMMENT '服务名称',
  `device` varchar(64) DEFAULT NULL COMMENT '设备名称(磁盘、网卡等)',
  `cluster_id` int DEFAULT NULL COMMENT '集群ID',
  `labels` json DEFAULT NULL COMMENT '所有标签信息(JSON格式)',
  `annotations` json DEFAULT NULL COMMENT '注解信息(JSON格式)',
  `starts_at` timestamp NULL DEFAULT NULL COMMENT '告警开始时间(Alertmanager格式)',
  `ends_at` timestamp NULL DEFAULT NULL COMMENT '告警结束时间(Alertmanager格式)',
  `alert_content` text COMMENT '告警内容详情',
  `recovery_attempts` int DEFAULT '0' COMMENT '已尝试恢复次数',
  `max_recovery_attempts` int DEFAULT '3' COMMENT '最大恢复次数',
  `status` enum('ACTIVE','RESOLVED','SILENCED','ESCALATED','FIRING') DEFAULT 'ACTIVE' COMMENT '告警当前状态',
  `sent_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '告警发送时间',
  `resolved_time` timestamp NULL DEFAULT NULL COMMENT '告警解决时间',
  `silence_until` timestamp NULL DEFAULT NULL COMMENT '静默截止时间',
  `can_escalate` tinyint(1) DEFAULT '1' COMMENT '是否允许升级',
  `escalation_reason` varchar(255) DEFAULT NULL COMMENT '升级原因',
  `send_count` int DEFAULT '0' COMMENT '告警发送次数',
  `last_send_time` timestamp NULL DEFAULT NULL COMMENT '最后发送时间',
  `is_processed` tinyint(1) DEFAULT '0' COMMENT '是否已处理',
  `processed_by` varchar(64) DEFAULT NULL COMMENT '处理人',
  `processed_at` timestamp NULL DEFAULT NULL COMMENT '处理时间',
  `notification_channels` varchar(255) NOT NULL DEFAULT 'wechat' COMMENT '通知渠道(wechat,email,sms)',
  PRIMARY KEY (`id`),
  KEY `idx_job_id` (`job_id`),
  KEY `idx_status` (`status`),
  KEY `idx_sent_time` (`sent_time`),
  KEY `idx_alert_type_title` (`alert_type`,`alert_title`),
  KEY `idx_send_count` (`send_count`),
  KEY `idx_last_send_time` (`last_send_time`),
  KEY `idx_sent_time_cleanup` (`sent_time`),
  KEY `idx_alert_id` (`alert_id`),
  KEY `idx_alertname_instance` (`alertname`,`instance`),
  KEY `idx_severity` (`severity`),
  KEY `idx_hostname` (`hostname`),
  KEY `idx_service` (`service`),
  KEY `idx_starts_at` (`starts_at`),
  KEY `idx_cluster_id` (`cluster_id`),
  KEY `idx_group_key` (`group_key`),
  KEY `idx_alert_dedup` (`alert_type`,`alert_title`(100),`status`,`sent_time` DESC),
  KEY `idx_status_type_time` (`status`,`alert_type`,`sent_time` DESC)
) ENGINE=InnoDB AUTO_INCREMENT=44111 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='告警历史表，兼容Flink作业告警和Alertmanager通用告警';

-- ----------------------------
-- Table structure for flink_cluster_cluster_metrics
-- ----------------------------
DROP TABLE IF EXISTS `flink_cluster_cluster_metrics`;
CREATE TABLE `flink_cluster_cluster_metrics` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键，自增ID',
  `collection_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '采集时间',
  `total_slots` int NOT NULL COMMENT 'Flink集群总插槽数',
  `available_slots` int NOT NULL COMMENT '可用插槽数',
  `running_jobs` int NOT NULL COMMENT '正在运行的作业数',
  `finished_jobs` int NOT NULL COMMENT '已完成作业数',
  `failed_jobs` int NOT NULL COMMENT '失败作业数',
  `cancelled_jobs` int NOT NULL COMMENT '取消作业数',
  `taskmanagers` int NOT NULL COMMENT 'TaskManager数量',
  `memory_usage_mb` int NOT NULL COMMENT '内存使用量(MB)',
  `cpu_usage_percent` float NOT NULL COMMENT 'CPU使用率(百分比)',
  PRIMARY KEY (`id`),
  KEY `idx_collection_time` (`collection_time`),
  KEY `idx_collection_time_cleanup` (`collection_time`)
) ENGINE=InnoDB AUTO_INCREMENT=59072 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Flink集群整体运行指标表，记录集群资源和作业统计信息';

-- ----------------------------
-- Table structure for flink_cluster_jar_history
-- ----------------------------
DROP TABLE IF EXISTS `flink_cluster_jar_history`;
CREATE TABLE `flink_cluster_jar_history` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键，自增ID',
  `jar_name` varchar(255) NOT NULL COMMENT '原始JAR文件名，不含UUID',
  `jar_path` varchar(512) NOT NULL COMMENT 'JAR完整路径',
  `upload_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '上传时间',
  `is_active` tinyint(1) DEFAULT '1' COMMENT '是否为当前活跃版本',
  PRIMARY KEY (`id`),
  KEY `idx_jar_name` (`jar_name`),
  KEY `idx_upload_time` (`upload_time`),
  KEY `idx_upload_time_cleanup` (`upload_time`,`is_active`)
) ENGINE=InnoDB AUTO_INCREMENT=583513 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Flink JAR文件历史表，记录所有上传的JAR包信息';

-- ----------------------------
-- Table structure for flink_cluster_job_metadata
-- ----------------------------
DROP TABLE IF EXISTS `flink_cluster_job_metadata`;
CREATE TABLE `flink_cluster_job_metadata` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键，自增ID',
  `job_id` varchar(64) DEFAULT NULL COMMENT 'Flink作业ID，首次注册可能为空',
  `job_name` varchar(255) NOT NULL COMMENT '作业名称',
  `job_description` text COMMENT '作业描述',
  `jar_name` varchar(255) NOT NULL COMMENT '原始JAR文件名，不含UUID',
  `init_jar_path` varchar(512) DEFAULT NULL COMMENT '初始化完整JAR路径',
  `last_jar_path` varchar(512) DEFAULT NULL COMMENT '最新的JAR路径，用于重启作业',
  `entry_class` varchar(255) NOT NULL COMMENT '入口类名',
  `program_args` text COMMENT '程序参数',
  `registration_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '注册时间',
  `last_check_time` timestamp NULL DEFAULT NULL COMMENT '最后检查时间',
  `last_running_time` timestamp NULL DEFAULT NULL COMMENT '最后运行时间',
  `last_stop_time` timestamp NULL DEFAULT NULL COMMENT '最后停止时间',
  `last_status` varchar(32) DEFAULT 'REGISTERED' COMMENT '最后状态',
  `recovery_attempts` int DEFAULT '0' COMMENT '恢复尝试次数',
  `total_failures` int DEFAULT '0' COMMENT '总失败次数',
  `auto_recovery` tinyint(1) DEFAULT '1' COMMENT '是否自动恢复(0是否,1是允许自动恢复)',
  `max_recovery_attempts` int DEFAULT '3' COMMENT '最大恢复尝试次数',
  `manual_stopped` tinyint(1) DEFAULT 0 COMMENT '是否手动停止（0=监控中, 1=已停止）',
  `is_alert_enabled` tinyint(1) DEFAULT 0 COMMENT '是否启用告警（0=静默监控, 1=发送告警，新Job默认关闭避免误报）',
  `savepoint_interval` int DEFAULT '24' COMMENT '保存点间隔(小时)',
  `last_savepoint_path` varchar(512) DEFAULT NULL COMMENT '最后保存点路径',
  `last_savepoint_time` timestamp NULL DEFAULT NULL COMMENT '最后保存点时间',
  `last_update_time` timestamp NULL DEFAULT NULL COMMENT '最后更新时间',
  `jar_id` varchar(64) DEFAULT NULL COMMENT 'Flink集群上的JAR ID',
  `error_message` text COMMENT '最近一次错误信息',
  `version` int DEFAULT '1' COMMENT '乐观锁版本号',
  `last_successful_check` timestamp NULL DEFAULT NULL COMMENT '最后成功检查时间',
  `consecutive_failures` int DEFAULT '0' COMMENT '连续失败次数',
  `last_error_type` varchar(50) DEFAULT NULL COMMENT '最后错误类型',
  `last_error_time` timestamp NULL DEFAULT NULL COMMENT '最后错误时间',
  `health_status` varchar(32) DEFAULT 'UNKNOWN' COMMENT '健康状态',
  `last_health_check` timestamp NULL DEFAULT NULL COMMENT '最后健康检查时间',
  `monitor_status` varchar(32) DEFAULT 'ACTIVE' COMMENT '监控状态',
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_job_name` (`job_name`),
  KEY `idx_job_id` (`job_id`),
  KEY `idx_status` (`last_status`),
  KEY `idx_last_update_time` (`last_update_time`),
  KEY `idx_last_status` (`last_status`),
  KEY `idx_health_status` (`health_status`),
  KEY `idx_status_health` (`last_status`, `health_status`),
  KEY `idx_monitor_status` (`monitor_status`),
  KEY `idx_last_running_time` (`last_running_time`),
  KEY `idx_alert_enabled` (`is_alert_enabled`),
  KEY `idx_monitor_alert` (`manual_stopped`, `is_alert_enabled`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci 
COMMENT='Flink作业元数据表，记录作业的详细运行和配置信息';

-- ----------------------------
-- Table structure for flink_cluster_job_metrics
-- ----------------------------
DROP TABLE IF EXISTS `flink_cluster_job_metrics`;
CREATE TABLE `flink_cluster_job_metrics` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键，自增ID',
  `timestamp` bigint NOT NULL COMMENT '采集时间戳',
  `job_id` varchar(100) NOT NULL COMMENT 'Flink作业ID',
  `job_name` varchar(255) NOT NULL COMMENT '作业名称',
  `status` varchar(50) NOT NULL COMMENT '作业状态',
  `restart_count` int DEFAULT '0' COMMENT '重启次数',
  `uptime` bigint DEFAULT '0' COMMENT '运行时长',
  `downtime` bigint DEFAULT '0' COMMENT '停机时长',
  `full_restarts` int DEFAULT '0' COMMENT '完全重启次数',
  `num_tasks` int DEFAULT '0' COMMENT '任务数量',
  `num_completed_tasks` int DEFAULT '0' COMMENT '已完成任务数量',
  `created_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`),
  KEY `timestamp` (`timestamp`),
  KEY `job_id` (`job_id`),
  KEY `idx_created_time_cleanup` (`created_time`),
  KEY `idx_created_job` (`created_time`,`job_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1427642 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Flink作业指标表，记录每个作业的运行状态和统计数据';

-- ----------------------------
-- Table structure for flink_cluster_restart_history
-- ----------------------------
DROP TABLE IF EXISTS `flink_cluster_restart_history`;
CREATE TABLE `flink_cluster_restart_history` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `restart_type` enum('SERVICE','JOB') NOT NULL COMMENT '重启类型：SERVICE-集群节点，JOB-作业',
  
  -- 集群节点重启专用字段
  `host` varchar(64) DEFAULT NULL COMMENT '主机名（集群节点专用）',
  `service_type` enum('JobManager','TaskManager') DEFAULT NULL COMMENT '服务类型（集群节点专用）',
  
  -- Job重启专用字段
  `job_id` varchar(64) DEFAULT NULL COMMENT '作业ID（Job专用）',
  `job_name` varchar(255) DEFAULT NULL COMMENT '作业名称（Job专用）',
  `jar_name` varchar(255) DEFAULT NULL COMMENT 'JAR文件名（Job专用）',
  `jar_path` varchar(512) DEFAULT NULL COMMENT 'JAR文件路径（Job专用）',
  `entry_class` varchar(255) DEFAULT NULL COMMENT '入口类（Job专用）',
  `program_args` text DEFAULT NULL COMMENT '程序参数（Job专用）',
  `savepoint_path` varchar(512) DEFAULT NULL COMMENT 'Savepoint路径（Job专用）',
  `use_savepoint` tinyint(1) DEFAULT 0 COMMENT '是否使用Savepoint恢复（Job专用）',
  `recovery_reason` varchar(255) DEFAULT NULL COMMENT '恢复原因（Job专用）',
  
  -- 通用字段
  `action` enum('RESTART','START','STOP','RECOVER') DEFAULT 'RESTART' COMMENT '操作类型',
  `status` enum('ATTEMPTING','SUCCESS','FAILED') DEFAULT 'ATTEMPTING' COMMENT '操作状态',
  `error_message` text COMMENT '错误信息',
  `created_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '开始时间',
  `completed_time` timestamp NULL DEFAULT NULL COMMENT '完成时间',
  `duration_seconds` int DEFAULT NULL COMMENT '操作耗时（秒）',
  `original_failure_reason` varchar(255) DEFAULT NULL COMMENT '原始失败原因（模板化）',
  `triggered_by` varchar(64) DEFAULT 'auto_monitor' COMMENT '触发者',
  
  PRIMARY KEY (`id`),
  KEY `idx_restart_type` (`restart_type`),
  KEY `idx_host_service` (`host`,`service_type`),
  KEY `idx_job_name` (`job_name`),
  KEY `idx_status` (`status`),
  KEY `idx_created_time` (`created_time`),
  KEY `idx_created_time_cleanup` (`created_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci 
COMMENT='统一重启历史表，记录集群节点和作业的重启历史';

-- ----------------------------
-- Table structure for flink_cluster_savepoint_history
-- ----------------------------
DROP TABLE IF EXISTS `flink_cluster_savepoint_history`;
CREATE TABLE `flink_cluster_savepoint_history` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键，自增ID',
  `job_id` varchar(64) NOT NULL COMMENT 'Flink作业ID',
  `job_name` varchar(255) NOT NULL COMMENT 'Flink作业名称',
  `savepoint_path` varchar(512) NOT NULL COMMENT '保存点路径',
  `creation_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `trigger_reason` enum('SCHEDULED','MANUAL','BEFORE_RESTART','UPGRADE') DEFAULT 'SCHEDULED' COMMENT '触发原因',
  `status` varchar(32) DEFAULT 'CREATED' COMMENT '保存点状态',
  PRIMARY KEY (`id`),
  KEY `idx_job_id` (`job_id`),
  KEY `idx_creation_time` (`creation_time`),
  KEY `idx_creation_time_status` (`creation_time`,`status`)
) ENGINE=InnoDB AUTO_INCREMENT=202439 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Flink保存点历史表，记录作业的保存点信息';

-- ----------------------------
-- Table structure for flink_cluster_system_config
-- ----------------------------
DROP TABLE IF EXISTS `flink_cluster_system_config`;
CREATE TABLE `flink_cluster_system_config` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键，自增ID',
  `config_key` varchar(100) NOT NULL COMMENT '配置键名',
  `config_group` varchar(50) DEFAULT 'general' COMMENT '配置分组',
  `config_value` text COMMENT '配置值',
  `config_type` enum('string','int','float','boolean','json','list') DEFAULT 'string' COMMENT '配置类型',
  `default_value` text COMMENT '默认值',
  `validation_rule` varchar(255) DEFAULT NULL COMMENT '验证规则',
  `is_required` tinyint(1) DEFAULT '0' COMMENT '是否必填',
  `is_sensitive` tinyint(1) DEFAULT '0' COMMENT '是否敏感信息',
  `restart_required` tinyint(1) DEFAULT '0' COMMENT '修改后是否需要重启',
  `is_active` tinyint(1) DEFAULT '1' COMMENT '是否启用',
  `sort_order` int DEFAULT '0' COMMENT '排序顺序',
  `description` varchar(255) DEFAULT NULL COMMENT '配置描述',
  `created_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `modified_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `config_key` (`config_key`),
  KEY `idx_config_group` (`config_group`),
  KEY `idx_is_active` (`is_active`),
  KEY `idx_sort_order` (`sort_order`),
  KEY `idx_group_key_active` (`config_group`,`config_key`,`is_active`)
) ENGINE=InnoDB AUTO_INCREMENT=121 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Flink集群系统配置表，记录全局配置信息';

-- ----------------------------
-- Records of flink_cluster_system_config
-- ----------------------------
BEGIN;
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (1, 'metrics_retention_days', 'general', '30', 'string', NULL, NULL, 0, 0, 0, 1, 0, '指标数据保留天数', '2025-05-24 17:57:47', '2025-07-17 16:53:13');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (2, 'default_savepoint_interval', 'general', '24', 'string', NULL, NULL, 0, 0, 0, 1, 0, '默认保存点创建间隔(小时)', '2025-05-24 17:57:47', '2025-05-24 17:57:47');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (3, 'max_savepoints', 'general', '5', 'string', NULL, NULL, 0, 0, 0, 1, 0, '每个作业保留的最大保存点数量', '2025-05-24 17:57:47', '2025-05-24 17:57:47');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (4, 'alert_escalation_hours', 'general', '24', 'string', NULL, NULL, 0, 0, 0, 1, 0, '告警升级时间(小时)', '2025-05-24 17:57:47', '2025-05-24 17:57:47');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (5, 'check_interval', 'general', '60', 'string', NULL, NULL, 0, 0, 0, 1, 0, '监控检查间隔(秒)', '2025-05-24 17:57:47', '2025-05-24 17:57:47');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (6, 'long_running_threshold', 'general', '72', 'string', NULL, NULL, 0, 0, 0, 1, 0, '长时间运行作业阈值(小时)', '2025-05-24 17:57:47', '2025-05-24 17:57:47');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (7, 'min_healthy_seconds', 'general', '600', 'string', NULL, NULL, 0, 0, 0, 1, 0, '作业健康运行最小秒数（单位：秒，建议10分钟=600）', '2025-07-15 16:46:54', '2025-07-15 16:46:54');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (8, 'cooldown_seconds', 'general', '1800', 'string', NULL, NULL, 0, 0, 0, 1, 0, '作业恢复冷却期（单位：秒，建议30分钟=1800）', '2025-07-15 16:46:54', '2025-07-15 16:46:54');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (9, 'alert_cooldown_minutes', 'general', '30', 'string', NULL, NULL, 0, 0, 0, 1, 0, '相同类型告警最小发送间隔（分钟）', '2025-07-17 09:53:02', '2025-07-17 09:53:02');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (10, 'max_alerts', 'general', '3', 'string', NULL, NULL, 0, 0, 0, 1, 0, '相同告警最大发送次数', '2025-07-17 09:53:02', '2025-07-17 09:53:02');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (12, 'logs_retention_days', 'general', '30', 'string', NULL, NULL, 0, 0, 0, 1, 0, '日志数据保留天数', '2025-07-17 16:53:13', '2025-07-17 16:53:13');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (13, 'restart_history_retention_days', 'general', '90', 'string', NULL, NULL, 0, 0, 0, 1, 0, '重启历史保留天数', '2025-07-17 16:53:13', '2025-07-17 16:53:13');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (14, 'alert_history_retention_days', 'general', '60', 'string', NULL, NULL, 0, 0, 0, 1, 0, '告警历史保留天数', '2025-07-17 16:53:13', '2025-07-17 16:53:13');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (15, 'jar_history_retention_days', 'general', '180', 'string', NULL, NULL, 0, 0, 0, 1, 0, 'JAR历史保留天数', '2025-07-17 16:53:13', '2025-07-17 16:53:13');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (16, 'cleanup_batch_size', 'general', '5000', 'string', NULL, NULL, 0, 0, 0, 1, 0, '清理批量大小', '2025-07-17 16:53:14', '2025-07-17 16:53:14');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (17, 'cleanup_enabled', 'general', 'true', 'string', NULL, NULL, 0, 0, 0, 1, 0, '是否启用自动清理', '2025-07-17 16:53:14', '2025-07-17 16:53:14');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (18, 'cleanup_hour', 'general', '2', 'string', NULL, NULL, 0, 0, 0, 1, 0, '每日清理执行时间(小时)', '2025-07-17 16:53:14', '2025-07-17 16:53:14');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (19, 'version', 'general', '2.0.0', 'string', '2.0.0', NULL, 1, 0, 1, 1, 1, '系统版本号', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (20, 'debug', 'general', 'false', 'boolean', 'false', NULL, 0, 0, 1, 1, 2, '是否启用调试模式', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (21, 'temp_dir', 'general', '/tmp/flink-monitor', 'string', '/tmp/flink-monitor', NULL, 0, 0, 1, 1, 3, '临时目录路径', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (22, 'db_host', 'database', '10.1.1.26', 'string', 'localhost', NULL, 1, 0, 1, 1, 10, '数据库主机地址', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (23, 'db_port', 'database', '3306', 'int', '3306', NULL, 1, 0, 1, 1, 11, '数据库端口', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (24, 'db_database', 'database', 'flink_cluster_monitor', 'string', 'flink_cluster_monitor', NULL, 1, 0, 1, 1, 12, '数据库名称', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (25, 'db_user', 'database', 'flink_cluster_monitor', 'string', 'root', NULL, 1, 1, 1, 1, 13, '数据库用户名', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (26, 'db_password', 'database', 'nXhkTJYJ7D5rhGT5', 'string', '', NULL, 1, 1, 1, 1, 14, '数据库密码', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (27, 'db_pool_size', 'database', '5', 'int', '5', NULL, 0, 0, 1, 1, 15, '连接池大小', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (28, 'db_connect_timeout', 'database', '10', 'int', '10', NULL, 0, 0, 1, 1, 16, '连接超时时间(秒)', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (29, 'db_read_timeout', 'database', '30', 'int', '30', NULL, 0, 0, 1, 1, 17, '读取超时时间(秒)', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (30, 'db_retry_interval', 'database', '5', 'int', '5', NULL, 0, 0, 0, 1, 18, '重试间隔(秒)', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (31, 'db_max_retries', 'database', '3', 'int', '3', NULL, 0, 0, 0, 1, 19, '最大重试次数', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (32, 'flink_rest_url', 'flink', 'http://10.1.1.68:8081', 'string', 'http://localhost:8081', NULL, 1, 0, 1, 1, 20, 'Flink REST API地址', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (33, 'flink_home', 'flink', '/opt/flink', 'string', '/opt/flink', NULL, 1, 0, 1, 1, 21, 'Flink安装目录', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (34, 'flink_savepoint_dir', 'flink', '/opt/flink/savepoints', 'string', '/opt/flink/savepoints', NULL, 1, 0, 0, 1, 22, 'SavePoint目录', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (35, 'flink_user_jars_dir', 'flink', '/opt/flink/userjars/flink-web-upload', 'string', '/opt/flink/userjars', NULL, 1, 0, 0, 1, 23, 'JAR文件目录', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (36, 'flink_request_timeout', 'flink', '30', 'int', '30', NULL, 0, 0, 0, 1, 24, 'API请求超时时间(秒)', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (37, 'flink_jobmanager_host', 'flink', '10.1.1.68', 'string', 'localhost', NULL, 1, 0, 1, 1, 25, 'JobManager主机地址', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (38, 'flink_jobmanager_port', 'flink', '8081', 'int', '8081', NULL, 1, 0, 1, 1, 26, 'JobManager端口', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (39, 'flink_taskmanager_web_port', 'flink', '9249', 'int', '9249', NULL, 0, 0, 0, 1, 27, 'TaskManager Web端口', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (40, 'flink_taskmanager_hosts', 'flink', '10.1.1.66,10.1.1.67,10.1.1.68', 'list', '', NULL, 1, 0, 1, 1, 28, 'TaskManager主机列表', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (41, 'flink_cluster_nodes', 'flink', '10.1.1.66,10.1.1.67,10.1.1.68', 'list', '', NULL, 1, 0, 1, 1, 29, '集群节点列表', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (42, 'flink_auto_restart_enabled', 'flink', 'true', 'boolean', 'true', NULL, 0, 0, 0, 1, 30, '是否启用自动重启', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (43, 'flink_restart_max_attempts', 'flink', '3', 'int', '3', NULL, 0, 0, 0, 1, 31, '最大重启尝试次数', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (44, 'flink_restart_interval', 'flink', '60', 'int', '60', NULL, 0, 0, 0, 1, 32, '重启间隔(秒)', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (45, 'flink_restart_on_metrics_failure', 'flink', 'false', 'boolean', 'false', NULL, 0, 0, 0, 1, 33, '是否因metrics异常重启', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (46, 'flink_metrics_endpoint_critical', 'flink', 'false', 'boolean', 'false', NULL, 0, 0, 0, 1, 34, 'metrics端点是否关键', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (47, 'flink_use_job_named_dirs', 'flink', 'true', 'boolean', 'true', NULL, 0, 0, 0, 1, 35, '是否使用作业命名目录', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (48, 'flink_use_date_dirs', 'flink', 'true', 'boolean', 'true', NULL, 0, 0, 0, 1, 36, '是否使用日期目录', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (49, 'monitor_cluster_check_interval', 'monitor', '60', 'int', '60', NULL, 0, 0, 0, 1, 40, '集群检查间隔(秒)', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (50, 'monitor_job_check_interval', 'monitor', '300', 'int', '300', NULL, 0, 0, 0, 1, 41, '作业检查间隔(秒)', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (51, 'monitor_memory_usage_threshold', 'monitor', '85', 'int', '85', NULL, 0, 0, 0, 1, 42, '内存使用率阈值(%)', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (52, 'monitor_slot_usage_threshold', 'monitor', '90', 'int', '90', NULL, 0, 0, 0, 1, 43, '插槽使用率阈值(%)', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (53, 'monitor_allow_no_savepoint_recovery', 'monitor', 'true', 'boolean', 'true', NULL, 0, 0, 0, 1, 44, '是否允许无SavePoint恢复', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (54, 'monitor_max_retries_without_savepoint', 'monitor', '3', 'int', '3', NULL, 0, 0, 0, 1, 45, '无SavePoint最大重试次数', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (55, 'monitor_max_recovery_attempts', 'monitor', '3', 'int', '3', NULL, 0, 0, 0, 1, 46, '最大恢复尝试次数', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (56, 'monitor_jm_memory', 'monitor', 'true', 'boolean', 'true', NULL, 0, 0, 0, 1, 47, '是否监控JobManager内存', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (57, 'monitor_tm_memory', 'monitor', 'true', 'boolean', 'true', NULL, 0, 0, 0, 1, 48, '是否监控TaskManager内存', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (58, 'monitor_slots', 'monitor', 'true', 'boolean', 'true', NULL, 0, 0, 0, 1, 49, '是否监控插槽使用', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (59, 'monitor_jobs', 'monitor', 'true', 'boolean', 'true', NULL, 0, 0, 0, 1, 50, '是否监控作业状态', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (60, 'monitor_long_running', 'monitor', 'true', 'boolean', 'true', NULL, 0, 0, 0, 1, 51, '是否监控长时间运行', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (61, 'monitor_long_running_threshold', 'monitor', '168', 'int', '168', NULL, 0, 0, 0, 1, 52, '长时间运行阈值(小时)', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (62, 'monitor_long_running_mode', 'monitor', 'debug', 'string', 'debug', NULL, 0, 0, 0, 1, 53, '长时间运行检查模式', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (63, 'monitor_timestamp_recovery_window_minutes', 'monitor', '30', 'int', '30', NULL, 0, 0, 0, 1, 54, '时间戳恢复窗口(分钟)', '2025-10-08 16:51:18', '2025-10-08 16:51:18');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (76, 'alert_enable', 'alert', 'true', 'boolean', 'true', NULL, 0, 0, 0, 1, 60, '是否启用告警', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (77, 'alert_min_level', 'alert', 'WARNING', 'string', 'WARNING', NULL, 0, 0, 0, 1, 62, '最小告警级别', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (78, 'alert_interval_minutes', 'alert', '30', 'int', '30', NULL, 0, 0, 0, 1, 63, '告警间隔(分钟)', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (79, 'alert_max_retries', 'alert', '3', 'int', '3', NULL, 0, 0, 0, 1, 64, '告警最大重试次数', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (80, 'alert_escalation_enabled', 'alert', 'true', 'boolean', 'true', NULL, 0, 0, 0, 1, 65, '是否启用告警升级', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (81, 'alert_escalation_interval', 'alert', '60', 'int', '60', NULL, 0, 0, 0, 1, 66, '告警升级间隔(分钟)', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (82, 'alert_wechat_enabled', 'alert', 'true', 'boolean', 'false', NULL, 0, 0, 0, 1, 67, '是否启用企业微信告警', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (83, 'alert_wechat_webhook', 'alert', 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=999122a3-c39a-4e0d-9444-ba848215df22', 'string', '', NULL, 0, 0, 1, 1, 68, '企业微信Webhook地址', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (84, 'alert_email_enabled', 'alert', 'false', 'boolean', 'false', NULL, 0, 0, 0, 1, 69, '是否启用邮件告警', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (85, 'alert_dingtalk_enabled', 'alert', 'false', 'boolean', 'false', NULL, 0, 0, 0, 1, 70, '是否启用钉钉告警', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (86, 'alert_sms_enabled', 'alert', 'false', 'boolean', 'false', NULL, 0, 0, 0, 1, 71, '是否启用短信告警', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (87, 'retention_data_days', 'retention', '30', 'int', '30', NULL, 0, 0, 0, 1, 80, '数据保留天数', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (88, 'retention_metrics_days', 'retention', '30', 'int', '30', NULL, 0, 0, 0, 1, 81, '指标保留天数', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (89, 'retention_logs_days', 'retention', '30', 'int', '30', NULL, 0, 0, 0, 1, 82, '日志保留天数', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (90, 'retention_restart_history_days', 'retention', '90', 'int', '90', NULL, 0, 0, 0, 1, 83, '重启历史保留天数', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (91, 'retention_alert_history_days', 'retention', '60', 'int', '60', NULL, 0, 0, 0, 1, 84, '告警历史保留天数', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (92, 'retention_jar_history_days', 'retention', '180', 'int', '180', NULL, 0, 0, 0, 1, 85, 'JAR历史保留天数', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (93, 'retention_max_savepoints', 'retention', '10', 'int', '10', NULL, 0, 0, 0, 1, 86, '最大SavePoint数量', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (94, 'retention_savepoint_days', 'retention', '7', 'int', '7', NULL, 0, 0, 0, 1, 87, 'SavePoint保留天数', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (95, 'retention_monitor_log_keep_days', 'retention', '3', 'int', '3', NULL, 0, 0, 0, 1, 88, '监控日志保留天数', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (96, 'retention_flink_log_keep_days', 'retention', '3', 'int', '3', NULL, 0, 0, 0, 1, 89, 'Flink日志保留天数', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (97, 'retention_cleanup_enabled', 'retention', 'true', 'boolean', 'true', NULL, 0, 0, 0, 1, 90, '是否启用自动清理', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (98, 'retention_cleanup_batch_size', 'retention', '5000', 'int', '5000', NULL, 0, 0, 0, 1, 91, '清理批量大小', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (99, 'retention_cleanup_hour', 'retention', '2', 'int', '2', NULL, 0, 0, 0, 1, 92, '清理执行时间(小时)', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (100, 'savepoint_max_retries', 'savepoint', '3', 'int', '3', NULL, 0, 0, 0, 1, 100, 'SavePoint最大重试次数', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (101, 'savepoint_retry_delay', 'savepoint', '30', 'int', '30', NULL, 0, 0, 0, 1, 101, '重试延迟时间(秒)', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (102, 'savepoint_resource_check_interval', 'savepoint', '60', 'int', '60', NULL, 0, 0, 0, 1, 102, '资源检查间隔(秒)', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (103, 'savepoint_max_concurrent', 'savepoint', '2', 'int', '2', NULL, 0, 0, 0, 1, 103, '最大并发SavePoint数量', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (104, 'savepoint_consecutive_failure_threshold', 'savepoint', '5', 'int', '5', NULL, 0, 0, 0, 1, 104, '连续失败阈值', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (105, 'savepoint_skip_after_failure_minutes', 'savepoint', '30', 'int', '30', NULL, 0, 0, 0, 1, 105, '失败后跳过时间(分钟)', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (106, 'savepoint_stats_retention_days', 'savepoint', '7', 'int', '7', NULL, 0, 0, 0, 1, 106, '统计信息保留天数', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (107, 'savepoint_cpu_threshold', 'savepoint', '85', 'int', '85', NULL, 0, 0, 0, 1, 107, 'CPU使用率阈值(%)', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (108, 'savepoint_memory_threshold', 'savepoint', '85', 'int', '85', NULL, 0, 0, 0, 1, 108, '内存使用率阈值(%)', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (109, 'savepoint_slot_threshold', 'savepoint', '85', 'int', '85', NULL, 0, 0, 0, 1, 109, '插槽使用率阈值(%)', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (110, 'savepoint_smart_retry_enabled', 'savepoint', 'true', 'boolean', 'true', NULL, 0, 0, 0, 1, 110, '是否启用智能重试', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (111, 'savepoint_resource_check_enabled', 'savepoint', 'true', 'boolean', 'true', NULL, 0, 0, 0, 1, 111, '是否启用资源检查', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (112, 'savepoint_timeout', 'savepoint', '120', 'int', '120', NULL, 0, 0, 0, 1, 112, 'SavePoint超时时间(秒)', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (113, 'savepoint_timeout_max_retries', 'savepoint', '2', 'int', '2', NULL, 0, 0, 0, 1, 113, '超时最大重试次数', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (114, 'savepoint_graceful_timeout_handling', 'savepoint', 'true', 'boolean', 'true', NULL, 0, 0, 0, 1, 114, '是否启用优雅超时处理', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (115, 'savepoint_timeout_check_interval', 'savepoint', '10', 'int', '10', NULL, 0, 0, 0, 1, 115, '超时检查间隔(秒)', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (116, 'log_dir', 'log', '/opt/flink/flink-monitor-python/logs/monitor', 'string', '/tmp/flink-monitor/logs', NULL, 0, 0, 1, 1, 120, '日志目录', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (117, 'log_level', 'log', 'INFO', 'string', 'INFO', NULL, 0, 0, 0, 1, 121, '日志级别', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (118, 'log_max_size', 'log', '10485760', 'int', '10485760', NULL, 0, 0, 0, 1, 122, '日志文件最大大小(字节)', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (119, 'log_backup_count', 'log', '5', 'int', '5', NULL, 0, 0, 0, 1, 123, '日志备份文件数量', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
INSERT INTO `flink_cluster_system_config` (`id`, `config_key`, `config_group`, `config_value`, `config_type`, `default_value`, `validation_rule`, `is_required`, `is_sensitive`, `restart_required`, `is_active`, `sort_order`, `description`, `created_time`, `modified_time`) VALUES (120, 'log_format', 'log', '%(asctime)s - %(name)s - %(levelname)s - %(message)s', 'string', '%(asctime)s - %(name)s - %(levelname)s - %(message)s', NULL, 0, 0, 1, 1, 124, '日志格式', '2025-10-08 17:30:34', '2025-10-08 17:30:34');
COMMIT;

-- ----------------------------
-- Table structure for flink_cluster_taskmanager_metrics
-- ----------------------------
DROP TABLE IF EXISTS `flink_cluster_taskmanager_metrics`;
CREATE TABLE `flink_cluster_taskmanager_metrics` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键，自增ID',
  `timestamp` bigint NOT NULL COMMENT '采集时间戳',
  `tm_id` varchar(100) NOT NULL COMMENT 'TaskManager ID',
  `heap_used` bigint DEFAULT '0' COMMENT '堆内存使用量',
  `heap_max` bigint DEFAULT '0' COMMENT '最大堆内存',
  `memory_usage` int DEFAULT '0' COMMENT '内存使用率',
  `created_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`),
  KEY `timestamp` (`timestamp`),
  KEY `tm_id` (`tm_id`),
  KEY `idx_created_time_cleanup` (`created_time`),
  KEY `idx_created_tm` (`created_time`,`tm_id`)
) ENGINE=InnoDB AUTO_INCREMENT=177298 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Flink TaskManager指标表，记录每个TaskManager的资源使用情况';

-- ----------------------------
-- Table structure for kafka_monitor_batch
-- ----------------------------
DROP TABLE IF EXISTS `kafka_monitor_batch`;
CREATE TABLE `kafka_monitor_batch` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '批次ID',
  `batch_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '批次时间',
  `cluster_name` varchar(100) NOT NULL DEFAULT 'default' COMMENT 'Kafka集群名称',
  `config_id` bigint DEFAULT NULL COMMENT 'Kafka配置ID（关联service_config表.id）',
  `total_topics` int NOT NULL DEFAULT '0' COMMENT '检查的topic总数',
  `total_partitions` int NOT NULL DEFAULT '0' COMMENT '检查的分区总数',
  `success_count` int NOT NULL DEFAULT '0' COMMENT '成功检查的数量',
  `failed_count` int NOT NULL DEFAULT '0' COMMENT '失败检查的数量',
  `status` enum('success','failed','partial') NOT NULL DEFAULT 'success' COMMENT '批次检查状态：success-成功,failed-失败,partial-部分成功',
  `error_message` text COMMENT '错误信息',
  `execution_time_seconds` decimal(10,2) DEFAULT NULL COMMENT '执行耗时（秒）',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间',
  PRIMARY KEY (`id`),
  KEY `idx_batch_time` (`batch_time`),
  KEY `idx_cluster_name` (`cluster_name`),
  KEY `idx_config_id` (`config_id`),
  KEY `idx_status` (`status`)
) ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Kafka监控批次记录表，记录每次监控任务的执行情况';

-- ----------------------------
-- Table structure for kafka_topic_monitor
-- ----------------------------
DROP TABLE IF EXISTS `kafka_topic_monitor`;
CREATE TABLE `kafka_topic_monitor` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `config_id` bigint DEFAULT NULL COMMENT 'kafka配置ID（关联service_config表.id）',
  `topic_name` varchar(255) NOT NULL COMMENT 'Kafka topic名称',
  `partition_id` int NOT NULL COMMENT '分区ID',
  `latest_offset` bigint NOT NULL DEFAULT '0' COMMENT '最新offset值',
  `latest_message` json DEFAULT NULL COMMENT '最新一条消息内容',
  `message_timestamp` timestamp NULL DEFAULT NULL COMMENT '最新消息的时间戳',
  `message_key` varchar(500) DEFAULT NULL COMMENT '最新消息的key',
  `consumer_lag` bigint NOT NULL DEFAULT '0' COMMENT '消费者滞后数量',
  `topic_size_bytes` bigint NOT NULL DEFAULT '0' COMMENT 'topic总大小(字节)',
  `is_monitored` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否监控此topic（默认启用监控，收集数据）',
  `is_alert_enabled` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否启用告警（默认关闭告警，避免新Topic误报）',
  `alert_threshold_hours` int NOT NULL DEFAULT '24' COMMENT '无最新数据告警阈值（小时），默认24小时',
  `webhook_url` varchar(500) DEFAULT NULL COMMENT '告警webhook地址（企业微信、钉钉等）',
  `status` enum('active','inactive','monitored_only','alert_disabled') NOT NULL DEFAULT 'active' COMMENT '状态字段：active-活跃,inactive-非活跃,monitored_only-仅监控,alert_disabled-告警禁用',
  `alert_first_send_time` time NOT NULL DEFAULT '09:30:00' COMMENT '首次告警发送时间（上班时间），格式：HH:MM:SS',
  `alert_second_interval` int NOT NULL DEFAULT '7200' COMMENT '第2次告警间隔（秒），从首次告警开始计算，默认2小时',
  `alert_third_interval` int NOT NULL DEFAULT '21600' COMMENT '第3次告警间隔（秒），从首次告警开始计算，默认6小时',
  `max_alert_count` int NOT NULL DEFAULT '3' COMMENT '单个告警周期内的最大告警次数',
  `alert_status` enum('normal','alerting','recovered') NOT NULL DEFAULT 'normal' COMMENT '告警状态：normal-正常,alerting-告警中,recovered-已恢复',
  `alert_count` int NOT NULL DEFAULT '0' COMMENT '当前告警周期内的告警次数',
  `last_alert_time` timestamp NULL DEFAULT NULL COMMENT '最后一次告警时间',
  `first_alert_time` timestamp NULL DEFAULT NULL COMMENT '本次告警周期的首次告警时间',
  `alert_history_id` int DEFAULT NULL COMMENT '关联的告警历史记录ID',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间',
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_config_topic_partition` (`config_id`,`topic_name`,`partition_id`),
  KEY `idx_config_id` (`config_id`),
  KEY `idx_topic_name` (`topic_name`),
  KEY `idx_updated_at` (`updated_at`),
  KEY `idx_message_timestamp` (`message_timestamp`),
  KEY `idx_is_monitored` (`is_monitored`),
  KEY `idx_is_alert_enabled` (`is_alert_enabled`),
  KEY `idx_status` (`status`),
  KEY `idx_alert_status` (`alert_status`),
  KEY `idx_last_alert_time` (`last_alert_time`),
  KEY `idx_created_at` (`created_at` DESC),
  KEY `idx_config_last_alert` (`config_id`,`last_alert_time` DESC)
) ENGINE=InnoDB AUTO_INCREMENT=140 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Kafka Topic监控信息表，按topic和分区记录监控数据';

-- ----------------------------
-- Table structure for scheduled_job_history
-- ----------------------------
DROP TABLE IF EXISTS `scheduled_job_history`;
CREATE TABLE `scheduled_job_history` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `job_id` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '任务ID',
  `success` tinyint(1) NOT NULL DEFAULT '0' COMMENT '执行是否成功',
  `processed_tables` int NOT NULL DEFAULT '0' COMMENT '处理的表数量',
  `success_tables` int NOT NULL DEFAULT '0' COMMENT '成功处理的表数量',
  `failed_tables` int NOT NULL DEFAULT '0' COMMENT '失败处理的表数量',
  `configs_processed` int NOT NULL DEFAULT '0' COMMENT '处理的配置数量',
  `configs_failed` int NOT NULL DEFAULT '0' COMMENT '失败的配置数量',
  `elapsed_seconds` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '执行耗时(秒)',
  `error_message` text COLLATE utf8mb4_unicode_ci COMMENT '错误信息',
  `executed_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '执行时间',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`),
  KEY `idx_job_id` (`job_id`),
  KEY `idx_executed_at` (`executed_at`),
  KEY `idx_success` (`success`),
  KEY `idx_job_executed` (`job_id`,`executed_at` DESC),
  KEY `idx_success_executed` (`success`,`executed_at` DESC)
) ENGINE=InnoDB AUTO_INCREMENT=245 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='定时任务执行历史表';

-- ----------------------------
-- Table structure for service_config
-- ----------------------------
DROP TABLE IF EXISTS `service_config`;
CREATE TABLE `service_config` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键，自增ID',
  `service_type` varchar(50) NOT NULL COMMENT '服务类型：flink, kafka, redis, starrocks, mysql, api_listener 等',
  `config_name` varchar(100) NOT NULL COMMENT '配置名称，如：生产环境、测试环境、开发环境等',
  `host` varchar(255) DEFAULT NULL COMMENT '主机地址/IP',
  `port` int DEFAULT NULL COMMENT '端口号',
  `username` varchar(100) DEFAULT NULL COMMENT '用户名',
  `password` varchar(255) DEFAULT NULL COMMENT '密码',
  `database` varchar(100) DEFAULT NULL COMMENT '数据库名',
  `protocol` varchar(20) DEFAULT 'http' COMMENT '协议类型：http, https, tcp, ssl 等',
  `path` varchar(500) DEFAULT NULL COMMENT '路径，如：/api/v1, /jars 等',
  `api_url` varchar(500) DEFAULT NULL COMMENT 'API触发接口地址',
  `request_template` json DEFAULT NULL COMMENT 'API请求JSON模板',
  `kafka_topics` json DEFAULT NULL COMMENT 'Kafka监听主题配置，JSON格式',
  `variable_mapping` json DEFAULT NULL COMMENT '变量映射配置，用于参数替换',
  `execution_timeout` int DEFAULT '300' COMMENT 'API执行超时时间（秒）',
  `extra_config` json DEFAULT NULL COMMENT '额外配置，JSON格式存储其他参数',
  `description` varchar(255) DEFAULT NULL COMMENT '配置描述',
  `is_active` tinyint(1) DEFAULT '1' COMMENT '是否激活，1=激活，0=禁用',
  `is_deleted` tinyint(1) DEFAULT '0' COMMENT '逻辑删除标记，0=未删除，1=已删除',
  `sort_order` int DEFAULT '0' COMMENT '排序顺序，数字越小越靠前',
  `created_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted_time` timestamp NULL DEFAULT NULL COMMENT '删除时间',
  `created_by` varchar(50) DEFAULT 'system' COMMENT '创建者',
  `updated_by` varchar(50) DEFAULT 'system' COMMENT '更新者',
  `deleted_by` varchar(50) DEFAULT NULL COMMENT '删除者',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_service_type_config_name` (`service_type`,`config_name`,`is_deleted`),
  KEY `idx_service_type` (`service_type`),
  KEY `idx_config_name` (`config_name`),
  KEY `idx_is_active` (`is_active`),
  KEY `idx_is_deleted` (`is_deleted`),
  KEY `idx_sort_order` (`sort_order`),
  KEY `idx_api_url` (`api_url`),
  KEY `idx_service_type_active` (`service_type`,`is_active`,`is_deleted`)
) ENGINE=InnoDB AUTO_INCREMENT=58 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='通用服务配置表（支持逻辑删除和API监听）';

-- ----------------------------
-- Records of service_config
-- ----------------------------
BEGIN;
INSERT INTO `service_config` (`id`, `service_type`, `config_name`, `host`, `port`, `username`, `password`, `database`, `protocol`, `path`, `api_url`, `request_template`, `kafka_topics`, `variable_mapping`, `execution_timeout`, `extra_config`, `description`, `is_active`, `is_deleted`, `sort_order`, `created_time`, `updated_time`, `deleted_time`, `created_by`, `updated_by`, `deleted_by`) VALUES (12, 'mysql', 'MYSQL(flink_cluster_monitor)', '10.1.1.26', 3306, 'root', 'nXhkTJYJ7D5rhGT5', 'flink_cluster_monitor', 'tcp', '/', NULL, NULL, NULL, NULL, 300, NULL, 'MySQL 默认环境', 1, 1, 1, '2025-09-21 14:24:07', '2025-09-30 17:29:20', '2025-09-30 17:29:20', 'web_ui', 'web_ui', 'web_ui');
INSERT INTO `service_config` (`id`, `service_type`, `config_name`, `host`, `port`, `username`, `password`, `database`, `protocol`, `path`, `api_url`, `request_template`, `kafka_topics`, `variable_mapping`, `execution_timeout`, `extra_config`, `description`, `is_active`, `is_deleted`, `sort_order`, `created_time`, `updated_time`, `deleted_time`, `created_by`, `updated_by`, `deleted_by`) VALUES (19, 'flink', 'FLINK(26)', '10.1.1.26', 8081, '', '', '', 'http', '/', NULL, NULL, NULL, NULL, 300, NULL, 'Flink 26测试环境', 1, 0, 2, '2025-09-21 20:48:12', '2025-09-21 20:48:12', NULL, 'web_ui', 'web_ui', NULL);
INSERT INTO `service_config` (`id`, `service_type`, `config_name`, `host`, `port`, `username`, `password`, `database`, `protocol`, `path`, `api_url`, `request_template`, `kafka_topics`, `variable_mapping`, `execution_timeout`, `extra_config`, `description`, `is_active`, `is_deleted`, `sort_order`, `created_time`, `updated_time`, `deleted_time`, `created_by`, `updated_by`, `deleted_by`) VALUES (21, 'flink', 'FLINK(68)', '10.1.1.68', 8081, '', '', '', 'http', '/', NULL, NULL, NULL, NULL, 300, NULL, 'Flink 68环境', 1, 0, 0, '2025-09-21 21:01:06', '2025-09-21 21:01:06', NULL, 'web_ui', 'web_ui', NULL);
INSERT INTO `service_config` (`id`, `service_type`, `config_name`, `host`, `port`, `username`, `password`, `database`, `protocol`, `path`, `api_url`, `request_template`, `kafka_topics`, `variable_mapping`, `execution_timeout`, `extra_config`, `description`, `is_active`, `is_deleted`, `sort_order`, `created_time`, `updated_time`, `deleted_time`, `created_by`, `updated_by`, `deleted_by`) VALUES (22, 'kafka', 'KAFKA生产环境(SASL)', '10.1.1.26', 9128, 'visitor', 'B8nbBCNPp3dz', '', 'SASL_PLAINTEXT', '/', NULL, NULL, NULL, NULL, 300, '{\"acks\": \"all\", \"retries\": 3, \"linger_ms\": 10, \"batch_size\": 16384, \"sasl_mechanism\": \"PLAIN\", \"compression_type\": \"gzip\", \"max_poll_records\": 1, \"auto_offset_reset\": \"latest\", \"bootstrap_servers\": [\"10.1.1.26:9128\"], \"security_protocol\": \"SASL_PLAINTEXT\", \"enable_auto_commit\": true, \"request_timeout_ms\": 60000, \"session_timeout_ms\": 30000, \"consumer_timeout_ms\": 10000}', 'Kafka SASL认证生产环境，从脚本kafka_consumer_forwarder.py提取', 1, 0, 1, '2025-09-22 11:33:21', '2025-09-22 11:33:21', NULL, 'system', 'system', NULL);
INSERT INTO `service_config` (`id`, `service_type`, `config_name`, `host`, `port`, `username`, `password`, `database`, `protocol`, `path`, `api_url`, `request_template`, `kafka_topics`, `variable_mapping`, `execution_timeout`, `extra_config`, `description`, `is_active`, `is_deleted`, `sort_order`, `created_time`, `updated_time`, `deleted_time`, `created_by`, `updated_by`, `deleted_by`) VALUES (50, 'api_listener', '爬虫队列接口', '10.1.1.26', 9128, 'visitor', 'B8nbBCNPp3dz', NULL, 'SASL_PLAINTEXT', NULL, 'http://10.1.1.26:7788/sadd_redis', '{\"seed_data\": [{\"video_id\": \"视频id\", \"prioritys\": 6, \"kafka_topic\": \"ods_dy_video_details_one\"}], \"queue_name\": \"ods_dy_video_details_one\"}', NULL, NULL, 300, NULL, '通用爬虫队列接口，用户可修改JSON模板适配不同业务', 1, 0, 1, '2025-09-22 11:33:21', '2025-09-22 11:33:21', NULL, 'system', 'system', NULL);
INSERT INTO `service_config` (`id`, `service_type`, `config_name`, `host`, `port`, `username`, `password`, `database`, `protocol`, `path`, `api_url`, `request_template`, `kafka_topics`, `variable_mapping`, `execution_timeout`, `extra_config`, `description`, `is_active`, `is_deleted`, `sort_order`, `created_time`, `updated_time`, `deleted_time`, `created_by`, `updated_by`, `deleted_by`) VALUES (51, 'redis', 'REDIS测试环境(19)', '10.1.1.19', 6379, '', 'mQFsv8jzorxI9yJN', '2', 'tcp', '/', NULL, NULL, NULL, NULL, 300, NULL, 'Redis生产环境DB7，从脚本export_dy_uid_to_redis.py提取，用于dy_uid映射', 1, 0, 1, '2025-09-24 17:51:13', '2025-09-24 17:51:13', NULL, 'web_ui', 'web_ui', NULL);
INSERT INTO `service_config` (`id`, `service_type`, `config_name`, `host`, `port`, `username`, `password`, `database`, `protocol`, `path`, `api_url`, `request_template`, `kafka_topics`, `variable_mapping`, `execution_timeout`, `extra_config`, `description`, `is_active`, `is_deleted`, `sort_order`, `created_time`, `updated_time`, `deleted_time`, `created_by`, `updated_by`, `deleted_by`) VALUES (54, 'mysql', 'MYSQL(flink_cluster_monitor)', '10.1.1.26', 3306, 'flink_cluster_monitor', 'nXhkTJYJ7D5rhGT5', 'flink_cluster_monitor', 'tcp', '/', NULL, NULL, NULL, NULL, 300, NULL, 'MySQL 默认环境', 1, 0, 1, '2025-09-30 17:29:20', '2025-09-30 17:29:20', NULL, 'web_ui', 'web_ui', NULL);
INSERT INTO `service_config` (`id`, `service_type`, `config_name`, `host`, `port`, `username`, `password`, `database`, `protocol`, `path`, `api_url`, `request_template`, `kafka_topics`, `variable_mapping`, `execution_timeout`, `extra_config`, `description`, `is_active`, `is_deleted`, `sort_order`, `created_time`, `updated_time`, `deleted_time`, `created_by`, `updated_by`, `deleted_by`) VALUES (56, 'starrocks', 'STARROCKS(72)', '10.1.1.72', 9030, 'zhangjie', 'X9DM4cW5&6@B', 'dws', 'tcp', '/', NULL, NULL, NULL, NULL, 300, NULL, 'Starrocks STARROCKS(72)配置', 1, 0, 0, '2025-09-30 17:42:59', '2025-09-30 17:42:59', NULL, 'web_ui', 'web_ui', NULL);
INSERT INTO `service_config` (`id`, `service_type`, `config_name`, `host`, `port`, `username`, `password`, `database`, `protocol`, `path`, `api_url`, `request_template`, `kafka_topics`, `variable_mapping`, `execution_timeout`, `extra_config`, `description`, `is_active`, `is_deleted`, `sort_order`, `created_time`, `updated_time`, `deleted_time`, `created_by`, `updated_by`, `deleted_by`) VALUES (57, 'starrocks', 'STARROCKS(65)', '10.1.1.65', 9030, 'zhangjie', 'X9DM4cW5&6@B', 'ods', 'tcp', '/', NULL, NULL, NULL, NULL, 300, NULL, 'StarRocks生产环境，从脚本export_dy_uid_to_redis.py提取，ODS数据层', 1, 0, 1, '2025-09-30 17:43:08', '2025-09-30 17:43:08', NULL, 'web_ui', 'web_ui', NULL);
COMMIT;

-- ----------------------------
-- Table structure for starrocks_cluster_monitor_config
-- ----------------------------
DROP TABLE IF EXISTS `starrocks_cluster_monitor_config`;
CREATE TABLE `starrocks_cluster_monitor_config` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `cluster_tag` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '集群标识(如: etl, api)',
  `config_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '配置名称',
  `config_desc` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '配置描述',
  `fe_master_node` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'FE主节点地址',
  `fe_slave_nodes` text COLLATE utf8mb4_unicode_ci COMMENT 'FE从节点列表(逗号分隔)',
  `has_fe_slaves` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否有FE从节点(1:有, 0:无)',
  `be_nodes` text COLLATE utf8mb4_unicode_ci COMMENT 'BE节点列表(逗号分隔)',
  `metrics_port` int NOT NULL DEFAULT '9010' COMMENT '集群监控端口',
  `fe_http_port` int NOT NULL DEFAULT '8060' COMMENT 'FE HTTP端口',
  `be_http_port` int NOT NULL DEFAULT '8071' COMMENT 'BE HTTP端口',
  `fe_log_port` int NOT NULL DEFAULT '9010' COMMENT 'FE日志端口',
  `control_script` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'StarRocks控制脚本路径',
  `starrocks_user` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'starrocks' COMMENT 'StarRocks用户',
  `prometheus_url` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Prometheus服务地址',
  `fe_query` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'FE节点Prometheus查询语句',
  `be_query` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'BE节点Prometheus查询语句',
  `enable_prometheus` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否启用Prometheus检查(1:启用, 0:禁用)',
  `prometheus_required` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Prometheus是否必需(1:必需失败时报错, 0:可选失败时降级)',
  `webhook_url` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '微信机器人Webhook地址',
  `is_alert` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否启用告警(1:启用, 0:禁用)',
  `alert_count` int NOT NULL DEFAULT '0' COMMENT '当前告警周期内的告警次数',
  `alert_interval` int NOT NULL DEFAULT '360' COMMENT '告警间隔时间(秒)',
  `max_alert_count` int NOT NULL DEFAULT '3' COMMENT '最大告警发送次数',
  `is_restart` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否启用自动重启(1:启用, 0:禁用)',
  `restart_count` int NOT NULL DEFAULT '0' COMMENT '当前重启周期内的重启次数',
  `max_restart_count` int NOT NULL DEFAULT '3' COMMENT '最大重启次数',
  `restart_timeout` int NOT NULL DEFAULT '120' COMMENT '重启超时时间(秒)',
  `ssh_user` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'root' COMMENT 'SSH用户',
  `ssh_timeout` int NOT NULL DEFAULT '30' COMMENT 'SSH超时时间(秒)',
  `is_monitor` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否启用监控(1:启用, 0:禁用)',
  `status` enum('running','stopped','enAlert','disAlert','enAll','disAll') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'enAll' COMMENT '状态(running:仅监控|stopped:停止|enAlert:启用告警|disAlert:禁用告警|enAll:全部启用|disAll:全部禁用)',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_cluster_config` (`cluster_tag`,`config_name`),
  KEY `idx_cluster_tag` (`cluster_tag`),
  KEY `idx_config_name` (`config_name`),
  KEY `idx_status` (`status`),
  KEY `idx_is_monitor` (`is_monitor`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='StarRocks健康监控系统配置表';

-- ----------------------------
-- Table structure for starrocks_cluster_monitor_config
-- ----------------------------
DROP TABLE IF EXISTS `starrocks_cluster_monitor_config`;
CREATE TABLE `starrocks_cluster_monitor_config` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `cluster_tag` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '集群标识(如: etl, api)',
  `config_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '配置名称',
  `config_desc` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '配置描述',
  `fe_master_node` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'FE主节点地址',
  `fe_slave_nodes` text COLLATE utf8mb4_unicode_ci COMMENT 'FE从节点列表(逗号分隔)',
  `has_fe_slaves` tinyint(1) DEFAULT '1' COMMENT '是否有FE从节点(1:有, 0:无)',
  `be_nodes` text COLLATE utf8mb4_unicode_ci COMMENT 'BE节点列表(逗号分隔)',
  `metrics_port` int DEFAULT '9010' COMMENT '集群监控端口',
  `fe_http_port` int DEFAULT '8060' COMMENT 'FE HTTP端口',
  `be_http_port` int DEFAULT '8071' COMMENT 'BE HTTP端口',
  `fe_log_port` int DEFAULT '9010' COMMENT 'FE日志端口',
  `starrocks_home` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT '/opt/datasophon/StarRocks-3.3.16' COMMENT 'StarRocks安装目录',
  `control_script` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'StarRocks控制脚本路径',
  `starrocks_user` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT 'starrocks' COMMENT 'StarRocks用户',
  `fe_log_dir` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'FE日志目录(默认为{starrocks_home}/fe/log)',
  `be_log_dir` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'BE日志目录(默认为{starrocks_home}/be/log)',
  `log_backup_dir` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT '/opt/starrocks_log_backup' COMMENT '日志备份目录',
  `log_keep_days` int DEFAULT '2' COMMENT '日志保留天数',
  `log_backup_days` int DEFAULT '7' COMMENT '备份日志保留天数',
  `prometheus_url` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Prometheus服务地址',
  `fe_query` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'FE节点Prometheus查询语句',
  `be_query` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'BE节点Prometheus查询语句',
  `enable_prometheus` tinyint(1) DEFAULT '1' COMMENT '是否启用Prometheus检查(1:启用, 0:禁用)',
  `prometheus_required` tinyint(1) DEFAULT '0' COMMENT 'Prometheus是否必需(1:必需失败时报错, 0:可选失败时降级)',
  `webhook_url` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '微信机器人Webhook地址',
  `is_alert` tinyint(1) DEFAULT '1' COMMENT '是否启用告警(1:启用, 0:禁用)',
  `alert_count` int DEFAULT '0' COMMENT '当前告警周期内的告警次数',
  `alert_interval` int DEFAULT '360' COMMENT '告警间隔时间(秒)',
  `max_alert_count` int DEFAULT '3' COMMENT '最大告警发送次数',
  `is_restart` tinyint(1) DEFAULT '1' COMMENT '是否启用自动重启(1:启用, 0:禁用)',
  `restart_count` int DEFAULT '0' COMMENT '当前重启周期内的重启次数',
  `max_restart_count` int DEFAULT '3' COMMENT '最大重启次数',
  `restart_timeout` int DEFAULT '120' COMMENT '重启超时时间(秒)',
  `ssh_user` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT 'root' COMMENT 'SSH用户',
  `ssh_timeout` int DEFAULT '30' COMMENT 'SSH超时时间(秒)',
  `is_monitor` tinyint(1) DEFAULT '1' COMMENT '是否启用监控(1:启用, 0:禁用)',
  `status` enum('running','stopped','enAlert','disAlert','enAll','disAll') COLLATE utf8mb4_unicode_ci DEFAULT 'enAll' COMMENT '状态(running:仅监控|stopped:停止|enAlert:启用告警|disAlert:禁用告警|enAll:全部启用|disAll:全部禁用)',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_cluster_config` (`cluster_tag`,`config_name`),
  KEY `idx_cluster_tag` (`cluster_tag`),
  KEY `idx_config_name` (`config_name`),
  KEY `idx_status` (`status`),
  KEY `idx_is_monitor` (`is_monitor`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='StarRocks健康监控系统配置表';

-- ----------------------------
-- Records of starrocks_cluster_monitor_config
-- ----------------------------
BEGIN;
INSERT INTO `starrocks_cluster_monitor_config` (`id`, `cluster_tag`, `config_name`, `config_desc`, `fe_master_node`, `fe_slave_nodes`, `has_fe_slaves`, `be_nodes`, `metrics_port`, `fe_http_port`, `be_http_port`, `fe_log_port`, `starrocks_home`, `control_script`, `starrocks_user`, `fe_log_dir`, `be_log_dir`, `log_backup_dir`, `log_keep_days`, `log_backup_days`, `prometheus_url`, `fe_query`, `be_query`, `enable_prometheus`, `prometheus_required`, `webhook_url`, `is_alert`, `alert_count`, `alert_interval`, `max_alert_count`, `is_restart`, `restart_count`, `max_restart_count`, `restart_timeout`, `ssh_user`, `ssh_timeout`, `is_monitor`, `status`, `created_at`, `updated_at`) VALUES (1, 'etl', 'default_cluster', 'ETL集群 - 3个FE节点(1主2从) + 5个BE节点', '10.1.1.65', '10.1.1.102,10.1.1.101', 1, '10.1.1.64,10.1.1.65,10.1.1.61,10.1.1.62,10.1.1.63', 9010, 8060, 8071, 9010, '/opt/datasophon/StarRocks-3.3.16', '/opt/datasophon/StarRocks-3.3.16/control_starrocks.sh', 'starrocks', NULL, NULL, '/opt/starrocks_log_backup', 2, 7, 'http://10.1.1.28:9090', 'up{job=\"StarRocks_Cluster01\", group=\"fe\"}', 'up{job=\"StarRocks_Cluster01\", group=\"be\"}', 1, 0, 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=47cf86f6-df1e-48a8-85bf-469673574569', 1, 0, 360, 3, 1, 0, 3, 120, 'root', 30, 1, 'enAll', '2025-10-23 16:50:30', '2025-10-23 16:50:30');
INSERT INTO `starrocks_cluster_monitor_config` (`id`, `cluster_tag`, `config_name`, `config_desc`, `fe_master_node`, `fe_slave_nodes`, `has_fe_slaves`, `be_nodes`, `metrics_port`, `fe_http_port`, `be_http_port`, `fe_log_port`, `starrocks_home`, `control_script`, `starrocks_user`, `fe_log_dir`, `be_log_dir`, `log_backup_dir`, `log_keep_days`, `log_backup_days`, `prometheus_url`, `fe_query`, `be_query`, `enable_prometheus`, `prometheus_required`, `webhook_url`, `is_alert`, `alert_count`, `alert_interval`, `max_alert_count`, `is_restart`, `restart_count`, `max_restart_count`, `restart_timeout`, `ssh_user`, `ssh_timeout`, `is_monitor`, `status`, `created_at`, `updated_at`) VALUES (2, 'api', 'default_cluster', 'API集群 - 1个FE节点 + 3个BE节点', '10.1.1.72', '', 0, '10.1.1.69,10.1.1.72,10.1.1.71', 9010, 8030, 8071, 9010, '/opt/datasophon/StarRocks-3.3.16', '/opt/datasophon/StarRocks-3.3.16/control_starrocks.sh', 'starrocks', NULL, NULL, '/opt/starrocks_log_backup', 2, 7, 'http://10.1.1.28:9090', 'up{job=\"StarRocks_Cluster02\", group=\"fe\"}', 'up{job=\"StarRocks_Cluster02\", group=\"be\"}', 1, 0, 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=your_webhook_key', 1, 0, 360, 3, 1, 0, 3, 120, 'root', 30, 1, 'enAll', '2025-10-23 16:50:30', '2025-10-23 16:50:30');
COMMIT;

-- ----------------------------
-- Table structure for starrocks_collection_logs
-- ----------------------------
DROP TABLE IF EXISTS `starrocks_collection_logs`;
CREATE TABLE `starrocks_collection_logs` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `config_id` int DEFAULT NULL COMMENT 'StarRocks配置ID，关联service_config.id',
  `task_type` varchar(50) NOT NULL COMMENT '任务类型: hourly_collect, daily_collect, manual_collect, table_sync',
  `database_name` varchar(100) DEFAULT NULL COMMENT '数据库名（可为空，表示全库操作）',
  `table_name` varchar(100) DEFAULT NULL COMMENT '表名（可为空，表示批量操作）',
  `start_time` timestamp NOT NULL COMMENT '开始时间',
  `end_time` timestamp NULL DEFAULT NULL COMMENT '结束时间',
  `status` enum('running','success','failed','timeout') DEFAULT 'running' COMMENT '执行状态',
  `processed_tables` int DEFAULT '0' COMMENT '处理的表数量',
  `success_tables` int DEFAULT '0' COMMENT '成功处理的表数量',
  `failed_tables` int DEFAULT '0' COMMENT '失败处理的表数量',
  `total_duration_ms` int DEFAULT '0' COMMENT '总耗时（毫秒）',
  `error_message` text COMMENT '错误信息',
  `result_summary` json DEFAULT NULL COMMENT '执行结果摘要（JSON格式）',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`),
  KEY `idx_task_type_time` (`task_type`,`start_time`),
  KEY `idx_status` (`status`),
  KEY `idx_created` (`created_at`),
  KEY `idx_config_id` (`config_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='数据收集任务执行日志表';

-- ----------------------------
-- Table structure for starrocks_monitor_config
-- ----------------------------
DROP TABLE IF EXISTS `starrocks_monitor_config`;
CREATE TABLE `starrocks_monitor_config` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `config_key` varchar(100) NOT NULL COMMENT '配置键名',
  `config_value` text COMMENT '配置值',
  `config_type` varchar(50) DEFAULT 'string' COMMENT '配置类型: string, int, boolean, json',
  `description` varchar(500) DEFAULT NULL COMMENT '配置说明',
  `is_active` tinyint(1) DEFAULT '1' COMMENT '是否生效 0-否 1-是',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_config_key` (`config_key`),
  KEY `idx_active` (`is_active`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='StarRocks监控配置表';

-- ----------------------------
-- Table structure for starrocks_restart_history
-- ----------------------------
DROP TABLE IF EXISTS `starrocks_restart_history`;
CREATE TABLE `starrocks_restart_history` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `restart_key` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '重启唯一标识键(node_component)',
  `node_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '节点名称',
  `component` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '组件类型(fe/be)',
  `cluster_tag` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '集群标识',
  `restart_command` text COLLATE utf8mb4_unicode_ci COMMENT '重启命令',
  `restart_result` enum('success','failure','timeout') COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '重启结果',
  `error_message` text COLLATE utf8mb4_unicode_ci COMMENT '错误信息',
  `execution_count` int NOT NULL DEFAULT '1' COMMENT '调度执行次数',
  `start_time` timestamp NOT NULL COMMENT '开始时间',
  `end_time` timestamp NOT NULL COMMENT '结束时间',
  `duration_seconds` int DEFAULT NULL COMMENT '持续时间(秒)',
  `status` enum('active','resolved','max_attempts') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active' COMMENT '重启状态',
  `total_attempts` int NOT NULL DEFAULT '1' COMMENT '总尝试次数',
  `successful_restarts` int NOT NULL DEFAULT '0' COMMENT '成功重启次数',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `idx_restart_key` (`restart_key`),
  KEY `idx_node_component` (`node_name`,`component`),
  KEY `idx_cluster_tag` (`cluster_tag`),
  KEY `idx_restart_result` (`restart_result`),
  KEY `idx_start_time` (`start_time`),
  KEY `idx_status` (`status`),
  KEY `idx_created_at` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='StarRocks重启历史表';

-- ----------------------------
-- Table structure for starrocks_table_columns
-- ----------------------------
DROP TABLE IF EXISTS `starrocks_table_columns`;
CREATE TABLE `starrocks_table_columns` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `config_id` int DEFAULT NULL COMMENT 'StarRocks配置ID，关联service_config.id',
  `table_id` bigint NOT NULL COMMENT '表ID，关联starrocks_tables.id',
  `database_name` varchar(100) NOT NULL COMMENT '数据库名',
  `table_name` varchar(100) NOT NULL COMMENT '表名',
  `column_name` varchar(100) NOT NULL COMMENT '字段名',
  `ordinal_position` int NOT NULL COMMENT '字段序号',
  `column_default` text COMMENT '默认值',
  `is_nullable` varchar(3) DEFAULT 'YES' COMMENT '是否允许NULL',
  `data_type` varchar(64) NOT NULL COMMENT '数据类型',
  `column_type` varchar(500) NOT NULL COMMENT '完整字段类型',
  `column_key` varchar(10) DEFAULT '' COMMENT '键类型: PRI, UNI, MUL',
  `extra` varchar(100) DEFAULT '' COMMENT '额外信息',
  `column_comment` text COMMENT '字段注释',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_config_table_column` (`config_id`,`table_id`,`column_name`),
  KEY `idx_db_table` (`database_name`,`table_name`),
  KEY `idx_column_key` (`column_key`),
  KEY `idx_config_id` (`config_id`),
  KEY `idx_config_db_table` (`config_id`,`database_name`,`table_name`)
) ENGINE=InnoDB AUTO_INCREMENT=82516 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='StarRocks表字段信息表';

-- ----------------------------
-- Table structure for starrocks_table_stats
-- ----------------------------
DROP TABLE IF EXISTS `starrocks_table_stats`;
CREATE TABLE `starrocks_table_stats` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `config_id` int NOT NULL COMMENT 'StarRocks配置ID（关联service_config.id）',
  `table_id` bigint NOT NULL COMMENT '表ID（关联starrocks_tables.id）',
  `database_name` varchar(100) NOT NULL COMMENT '数据库名（冗余字段，便于查询）',
  `table_name` varchar(100) NOT NULL COMMENT '表名（冗余字段，便于查询）',
  `stat_time` timestamp NOT NULL COMMENT '统计时间',
  `stat_type` enum('manual','hourly') NOT NULL DEFAULT 'manual' COMMENT '统计类型: manual-手动统计, hourly-小时统计',
  `total_rows` bigint DEFAULT '0' COMMENT '总行数',
  `data_length` bigint DEFAULT '0' COMMENT '数据大小（字节）',
  `index_length` bigint DEFAULT '0' COMMENT '索引大小（字节）',
  `previous_increment_rows` bigint DEFAULT '0' COMMENT '上次增量（记录当时的上次增量值）',
  `current_increment_rows` bigint DEFAULT '0' COMMENT '当前增量（本次相对上次的增量，可为负数）',
  `total_increment_rows` bigint DEFAULT '0' COMMENT '总增量（记录当时的当天累计增量）',
  `previous_increment_data` bigint DEFAULT '0' COMMENT '上次数据增量（字节）',
  `current_increment_data` bigint DEFAULT '0' COMMENT '当前数据增量（字节，可为负数）',
  `total_increment_data` bigint DEFAULT '0' COMMENT '总数据增量（字节，当天累计）',
  `collection_method` enum('information_schema','count_query','show_table_status') DEFAULT 'information_schema' COMMENT '数据收集方式',
  `collection_duration_ms` int DEFAULT '0' COMMENT '数据收集耗时（毫秒）',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`),
  KEY `idx_table_time` (`table_id`,`stat_time`),
  KEY `idx_db_table_time` (`database_name`,`table_name`,`stat_time`),
  KEY `idx_stat_type_time` (`stat_type`,`stat_time`),
  KEY `idx_stat_time_desc` (`stat_time` DESC),
  KEY `idx_config_id` (`config_id`),
  KEY `idx_config_table_time` (`config_id`,`table_id`,`stat_time`),
  KEY `idx_current_increment` (`current_increment_rows`),
  KEY `idx_total_increment` (`total_increment_rows`),
  KEY `idx_created` (`created_at`)
) ENGINE=InnoDB AUTO_INCREMENT=125421 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='StarRocks表数据统计历史表(三增量设计)';

-- ----------------------------
-- Table structure for starrocks_tables
-- ----------------------------
DROP TABLE IF EXISTS `starrocks_tables`;
CREATE TABLE `starrocks_tables` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '表ID',
  `config_id` int NOT NULL COMMENT 'StarRocks配置ID（关联service_config.id）',
  `database_name` varchar(128) NOT NULL COMMENT '数据库名',
  `table_name` varchar(128) NOT NULL COMMENT '表名',
  `table_comment` text COMMENT '表注释',
  `engine` varchar(64) DEFAULT 'StarRocks' COMMENT '引擎类型',
  `table_type` varchar(64) DEFAULT 'BASE TABLE' COMMENT '表类型',
  `is_partitioned` tinyint(1) DEFAULT '0' COMMENT '是否分区表',
  `partition_field` varchar(128) DEFAULT NULL COMMENT '分区字段',
  `key_type` varchar(32) DEFAULT NULL COMMENT '键类型(PRIMARY KEY/DUPLICATE KEY/UNIQUE KEY/AGGREGATE KEY)',
  `storage_medium` varchar(16) DEFAULT 'HDD' COMMENT '存储介质(SSD/HDD)',
  `total_columns` int DEFAULT '0' COMMENT '字段总数',
  `monitor_enabled` tinyint(1) DEFAULT '1' COMMENT '是否启用监控',
  `latest_total_rows` bigint DEFAULT '0' COMMENT '最新总行数',
  `latest_data_length` bigint DEFAULT '0' COMMENT '最新数据大小(字节)',
  `latest_index_length` bigint DEFAULT '0' COMMENT '最新索引大小(字节)',
  `previous_increment_rows` bigint DEFAULT '0' COMMENT '上次增量（上一次统计时的增量值）',
  `current_increment_rows` bigint DEFAULT '0' COMMENT '当前增量（本次相对上次的增量）',
  `total_increment_rows` bigint DEFAULT '0' COMMENT '总增量（当天0点到当前的累计增量）',
  `previous_increment_data` bigint DEFAULT '0' COMMENT '上次数据增量(字节)',
  `current_increment_data` bigint DEFAULT '0' COMMENT '当前数据增量(字节)',
  `total_increment_data` bigint DEFAULT '0' COMMENT '总数据增量(字节，当天累计)',
  `today_start_total_rows` bigint DEFAULT '0' COMMENT '今天0点时的总行数（用于计算当天总增量）',
  `today_start_data_length` bigint DEFAULT '0' COMMENT '今天0点时的数据大小',
  `today_start_date` date DEFAULT NULL COMMENT '当前日期（用于判断是否跨天）',
  `last_stat_time` timestamp NULL DEFAULT NULL COMMENT '最后统计时间',
  `last_stat_type` enum('manual','hourly') DEFAULT 'manual' COMMENT '上次统计类型(manual=手动, hourly=小时定时)',
  `last_sync_time` timestamp NULL DEFAULT NULL COMMENT '最后同步时间',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_config_db_table` (`config_id`,`database_name`,`table_name`),
  KEY `idx_config_id` (`config_id`),
  KEY `idx_database_name` (`database_name`),
  KEY `idx_monitor_enabled` (`monitor_enabled`),
  KEY `idx_last_stat_time` (`last_stat_time`),
  KEY `idx_current_increment_rows` (`current_increment_rows`),
  KEY `idx_total_increment_rows` (`total_increment_rows`)
) ENGINE=InnoDB AUTO_INCREMENT=541 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='StarRocks表管理主表(三增量设计)';

-- ----------------------------
-- View structure for v_starrocks_table_summary
-- ----------------------------
DROP VIEW IF EXISTS `v_starrocks_table_summary`;
CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `v_starrocks_table_summary` AS select `t`.`id` AS `id`,`t`.`config_id` AS `config_id`,`sc`.`config_name` AS `starrocks_config_name`,`sc`.`host` AS `starrocks_host`,`sc`.`port` AS `starrocks_port`,`t`.`database_name` AS `database_name`,`t`.`table_name` AS `table_name`,`t`.`table_comment` AS `table_comment`,`t`.`engine` AS `engine`,`t`.`table_type` AS `table_type`,`t`.`is_partitioned` AS `is_partitioned`,`t`.`partition_field` AS `partition_field`,`t`.`key_type` AS `key_type`,`t`.`storage_medium` AS `storage_medium`,`t`.`total_columns` AS `total_columns`,`t`.`monitor_enabled` AS `monitor_enabled`,`t`.`last_sync_time` AS `last_sync_time`,`t`.`latest_total_rows` AS `total_rows`,`t`.`latest_data_length` AS `data_length`,`t`.`latest_index_length` AS `index_length`,`t`.`last_stat_time` AS `last_stat_time`,`t`.`previous_increment_rows` AS `previous_increment_rows`,`t`.`current_increment_rows` AS `current_increment_rows`,`t`.`total_increment_rows` AS `total_increment_rows`,`t`.`previous_increment_data` AS `previous_increment_data`,`t`.`current_increment_data` AS `current_increment_data`,`t`.`total_increment_data` AS `total_increment_data`,`t`.`current_increment_rows` AS `hourly_increment_rows`,`t`.`current_increment_rows` AS `daily_increment_rows`,`t`.`last_stat_type` AS `last_stat_type`,`t`.`created_at` AS `created_at`,`t`.`updated_at` AS `updated_at` from (`starrocks_tables` `t` left join `service_config` `sc` on(((`t`.`config_id` = `sc`.`id`) and (`sc`.`service_type` = 'starrocks'))));

-- ----------------------------
-- View structure for v_system_config_grouped
-- ----------------------------
DROP VIEW IF EXISTS `v_system_config_grouped`;
CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `v_system_config_grouped` AS select `flink_cluster_system_config`.`config_group` AS `config_group`,`flink_cluster_system_config`.`config_key` AS `config_key`,`flink_cluster_system_config`.`config_value` AS `config_value`,`flink_cluster_system_config`.`config_type` AS `config_type`,`flink_cluster_system_config`.`default_value` AS `default_value`,`flink_cluster_system_config`.`description` AS `description`,`flink_cluster_system_config`.`is_required` AS `is_required`,`flink_cluster_system_config`.`is_sensitive` AS `is_sensitive`,`flink_cluster_system_config`.`restart_required` AS `restart_required`,`flink_cluster_system_config`.`is_active` AS `is_active`,`flink_cluster_system_config`.`sort_order` AS `sort_order`,`flink_cluster_system_config`.`created_time` AS `created_time`,`flink_cluster_system_config`.`modified_time` AS `modified_time` from `flink_cluster_system_config` where (`flink_cluster_system_config`.`is_active` = 1) order by `flink_cluster_system_config`.`config_group`,`flink_cluster_system_config`.`sort_order`,`flink_cluster_system_config`.`config_key`;

-- ----------------------------
-- Procedure structure for ValidateConfig
-- ----------------------------
DROP PROCEDURE IF EXISTS `ValidateConfig`;
delimiter ;;
CREATE PROCEDURE `ValidateConfig`(IN p_config_key VARCHAR(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
    IN p_config_value TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
    OUT p_is_valid BOOLEAN,
    OUT p_error_message VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci)
BEGIN
    DECLARE v_config_type VARCHAR(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
    DECLARE v_validation_rule VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
    DECLARE v_is_required TINYINT(1);
    
    -- 获取配置信息
    SELECT config_type, validation_rule, is_required
    INTO v_config_type, v_validation_rule, v_is_required
    FROM flink_cluster_system_config
    WHERE config_key = p_config_key AND is_active = 1;
    
    -- 默认值
    SET p_is_valid = TRUE;
    SET p_error_message = '';
    
    -- 检查是否存在
    IF v_config_type IS NULL THEN
        SET p_is_valid = FALSE;
        SET p_error_message = CONCAT('配置项不存在: ', p_config_key);
    -- 检查必填项
    ELSEIF v_is_required = 1 AND (p_config_value IS NULL OR p_config_value = '') THEN
        SET p_is_valid = FALSE;
        SET p_error_message = CONCAT('必填配置项不能为空: ', p_config_key);
    -- 类型验证
    ELSEIF v_config_type = 'int' AND p_config_value NOT REGEXP '^[0-9]+$' THEN
        SET p_is_valid = FALSE;
        SET p_error_message = CONCAT('配置值必须为整数: ', p_config_key);
    ELSEIF v_config_type = 'float' AND p_config_value NOT REGEXP '^[0-9]*\\.?[0-9]+$' THEN
        SET p_is_valid = FALSE;
        SET p_error_message = CONCAT('配置值必须为数字: ', p_config_key);
    ELSEIF v_config_type = 'boolean' AND p_config_value NOT IN ('true', 'false', '1', '0') THEN
        SET p_is_valid = FALSE;
        SET p_error_message = CONCAT('配置值必须为布尔值: ', p_config_key);
    END IF;
    
END
;;
delimiter ;


-- ----------------------------
-- Table structure for report_config_notifications
-- ----------------------------
DROP TABLE IF EXISTS `report_config_notifications`;
CREATE TABLE `report_config_notifications` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `report_config_id` bigint NOT NULL COMMENT '关联report_configs.id（FK）',
  `webhook_id` bigint NOT NULL COMMENT '关联report_webhook_library.id（FK）',
  `enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否启用该条通知',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_config_webhook` (`report_config_id`,`webhook_id`),
  KEY `idx_cfg` (`report_config_id`),
  KEY `idx_webhook` (`webhook_id`),
  CONSTRAINT `fk_report_config_notifications_config_id` FOREIGN KEY (`report_config_id`) REFERENCES `report_configs` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_report_config_notifications_webhook_id` FOREIGN KEY (`webhook_id`) REFERENCES `report_webhook_library` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='报表配置关联的Webhook（支持多个）';

-- ----------------------------
-- Table structure for report_configs
-- ----------------------------
DROP TABLE IF EXISTS `report_configs`;
CREATE TABLE `report_configs` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `config_name` varchar(200) NOT NULL COMMENT '配置名称（展示给用户）',
  `template_code` varchar(100) NOT NULL COMMENT '关联模板编码（FK→report_templates.template_code）',
  `params` json NOT NULL COMMENT '运行参数（时间范围、实例IDs、阈值、筛选等）',
  `schedule_enabled` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否启用定时',
  `schedule_cron` varchar(100) DEFAULT NULL COMMENT 'cron表达式，如 0 9 * * *',
  `output_formats` json NOT NULL COMMENT '生成的输出格式：["html","excel"]',
  `notify_on_success` tinyint(1) NOT NULL DEFAULT '0' COMMENT '生成成功后是否发送通知',
  `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否启用该配置',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `idx_template` (`template_code`),
  KEY `idx_active_schedule` (`is_active`,`schedule_enabled`),
  KEY `idx_config_name` (`config_name`),
  CONSTRAINT `fk_report_configs_template_code` FOREIGN KEY (`template_code`) REFERENCES `report_templates` (`template_code`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='报表配置表（含定时与通知开关）';

-- ----------------------------
-- Table structure for report_delivery_logs
-- ----------------------------
DROP TABLE IF EXISTS `report_delivery_logs`;
CREATE TABLE `report_delivery_logs` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `run_id` bigint NOT NULL COMMENT '关联report_runs.id（FK）',
  `webhook_id` bigint NOT NULL COMMENT '关联report_webhook_library.id（FK）',
  `status` enum('success','failed') NOT NULL COMMENT '发送结果',
  `request_body` text COMMENT '请求内容（序列化）',
  `response_code` int DEFAULT NULL COMMENT '响应状态码/HTTP码',
  `response_body` text COMMENT '响应体（序列化）',
  `error_message` text COMMENT '错误信息',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间',
  PRIMARY KEY (`id`),
  KEY `idx_run` (`run_id`),
  KEY `idx_webhook` (`webhook_id`),
  KEY `idx_status` (`status`),
  KEY `idx_created` (`created_at`),
  CONSTRAINT `fk_report_delivery_logs_run_id` FOREIGN KEY (`run_id`) REFERENCES `report_runs` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_report_delivery_logs_webhook_id` FOREIGN KEY (`webhook_id`) REFERENCES `report_webhook_library` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='报表通知发送日志';

-- ----------------------------
-- Table structure for report_files
-- ----------------------------
DROP TABLE IF EXISTS `report_files`;
CREATE TABLE `report_files` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `run_id` bigint NOT NULL COMMENT '关联report_runs.id（FK）',
  `file_type` enum('html','excel','csv','pdf') NOT NULL COMMENT '文件类型',
  `file_path` varchar(512) NOT NULL COMMENT '文件存储路径（相对/绝对）',
  `file_size` bigint NOT NULL DEFAULT '0' COMMENT '文件大小（字节）',
  `checksum` varchar(64) DEFAULT NULL COMMENT '文件校验和',
  `previewable` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否可在线预览（仅HTML）',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`),
  KEY `idx_run` (`run_id`),
  KEY `idx_type` (`file_type`),
  CONSTRAINT `fk_report_files_run_id` FOREIGN KEY (`run_id`) REFERENCES `report_runs` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=121 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='报表产物文件';

-- ----------------------------
-- Table structure for report_runs
-- ----------------------------
DROP TABLE IF EXISTS `report_runs`;
CREATE TABLE `report_runs` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `report_config_id` bigint DEFAULT NULL COMMENT '关联配置ID（一次性运行可为空，FK）',
  `template_code` varchar(100) NOT NULL COMMENT '模板编码（冗余便于查询，FK）',
  `title` varchar(255) DEFAULT NULL COMMENT '报表标题（自定义标题，用于不同使用场景）',
  `params` json NOT NULL COMMENT '本次运行使用的参数（包含临时覆盖）',
  `output_formats` json DEFAULT NULL COMMENT '本次运行的输出格式列表（临时覆盖）',
  `time_start` datetime DEFAULT NULL COMMENT '统计开始时间',
  `time_end` datetime DEFAULT NULL COMMENT '统计结束时间',
  `trigger_type` enum('manual','scheduled','api') NOT NULL DEFAULT 'manual' COMMENT '触发方式',
  `status` enum('queued','running','success','failed') NOT NULL DEFAULT 'queued' COMMENT '运行状态',
  `progress` int NOT NULL DEFAULT '0' COMMENT '进度(0-100)',
  `error_message` text COMMENT '错误信息',
  `summary` json DEFAULT NULL COMMENT '概要指标与Top列表（供历史列表展示）',
  `notify_requested` tinyint(1) NOT NULL DEFAULT '0' COMMENT '本次运行是否请求发送通知（临时覆盖）',
  `notify_channels` json DEFAULT NULL COMMENT '本次运行通知渠道数组（临时覆盖）',
  `notify_params` json DEFAULT NULL COMMENT '本次运行各渠道参数（webhook/收件人等）',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `finished_at` timestamp NULL DEFAULT NULL COMMENT '完成时间',
  PRIMARY KEY (`id`),
  KEY `idx_template_time` (`template_code`,`created_at`),
  KEY `idx_status` (`status`),
  KEY `idx_run_time` (`created_at`,`finished_at`),
  KEY `fk_report_runs_config_id` (`report_config_id`),
  CONSTRAINT `fk_report_runs_config_id` FOREIGN KEY (`report_config_id`) REFERENCES `report_configs` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `fk_report_runs_template_code` FOREIGN KEY (`template_code`) REFERENCES `report_templates` (`template_code`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='报表运行历史（支持一次性运行级别的通知覆盖）';

-- ----------------------------
-- Table structure for report_templates
-- ----------------------------
DROP TABLE IF EXISTS `report_templates`;
CREATE TABLE `report_templates` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `template_code` varchar(100) NOT NULL COMMENT '模板唯一编码，如 starrocks_query_slow',
  `template_name` varchar(200) NOT NULL COMMENT '模板显示名称',
  `template_group` varchar(50) NOT NULL COMMENT '分组：starrocks/kafka/flink/alerts/mixed',
  `description` varchar(500) DEFAULT NULL COMMENT '模板说明',
  `param_schema` json NOT NULL COMMENT '参数JSON Schema，定义前端动态表单',
  `default_params` json NOT NULL COMMENT '默认参数',
  `output_formats` json NOT NULL COMMENT '支持输出格式数组，如 ["html","excel"]',
  `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否启用',
  `version` int NOT NULL DEFAULT '1' COMMENT '模板版本',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_template_code` (`template_code`),
  KEY `idx_group_active` (`template_group`,`is_active`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='报表模板注册表';

-- ----------------------------
-- Table structure for report_webhook_library
-- ----------------------------
DROP TABLE IF EXISTS `report_webhook_library`;
CREATE TABLE `report_webhook_library` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `name` varchar(100) NOT NULL COMMENT 'Webhook名称（方便识别）',
  `channel_type` enum('wecom','dingtalk','feishu','email','custom') NOT NULL DEFAULT 'wecom' COMMENT '渠道类型',
  `webhook_url` varchar(500) DEFAULT NULL COMMENT 'Webhook地址（wecom/dingtalk/feishu使用）',
  `wecom_mention` json DEFAULT NULL COMMENT '企业微信@配置：{"to_user":[],"to_party":[],"to_tag":[],"is_all":false}',
  `email_recipients` json DEFAULT NULL COMMENT '邮件收件人数组',
  `email_cc` json DEFAULT NULL COMMENT '邮件抄送数组',
  `email_subject_template` varchar(200) DEFAULT NULL COMMENT '邮件主题模板',
  `email_body_template` text COMMENT '邮件正文模板',
  `description` varchar(500) DEFAULT NULL COMMENT '描述信息',
  `extra_config` json DEFAULT NULL COMMENT '扩展配置（钉钉/飞书特有参数等）',
  `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否启用',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_name` (`name`),
  KEY `idx_channel_type` (`channel_type`),
  KEY `idx_active` (`is_active`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='报表Webhook地址库（集中管理所有告警配置）';



-- ----------------------------
-- Records of report_templates (初始化报表模板数据)
-- ----------------------------
-- 已清理所有模板初始化数据，后续将逐个实现新模板
-- 如需清理数据库中的模板数据，请执行 sql/clean_report_templates.sql

-- BEGIN;
-- INSERT IGNORE INTO `report_templates` 
--   (`template_code`, `template_name`, `template_group`, `description`, `param_schema`, `default_params`, `output_formats`, `is_active`, `version`) 
-- VALUES 
--   -- 1. StarRocks表概览
--   ('starrocks_table_overview', 'StarRocks表数据概览', 'starrocks', 
--    '统计StarRocks表的数据变化情况，包括无新增数据的表和数据增量排名',
--    '{
--      "type": "object",
--      "properties": {
--        "time_start": {"type": "string", "format": "date-time", "title": "开始时间", "description": "统计开始时间"},
--        "time_end": {"type": "string", "format": "date-time", "title": "结束时间", "description": "统计结束时间"},
--        "instance_ids": {"type": "array", "items": {"type": "integer"}, "title": "集群实例", "description": "StarRocks集群实例ID列表，留空表示全部"}
--      },
--      "required": ["time_start", "time_end"]
--    }',
--    '{"time_start": "2024-01-01 00:00:00", "time_end": "2024-01-02 00:00:00", "instance_ids": []}',
--    '["html", "excel"]', 1, 1),
-- 
--   -- 2. Kafka Topic概览
--   ('kafka_topic_overview', 'Kafka Topic数据概览', 'kafka',
--    '统计Kafka Topic的数据变化情况和消费情况',
--    '{
--      "type": "object",
--      "properties": {
--        "time_start": {"type": "string", "format": "date-time", "title": "开始时间"},
--        "time_end": {"type": "string", "format": "date-time", "title": "结束时间"},
--        "instance_ids": {"type": "array", "items": {"type": "integer"}, "title": "监控实例", "description": "Kafka监控实例ID列表"}
--      },
--      "required": ["time_start", "time_end"]
--    }',
--    '{"time_start": "2024-01-01 00:00:00", "time_end": "2024-01-02 00:00:00", "instance_ids": []}',
--    '["html", "excel"]', 1, 1),
-- 
--   -- 3. Flink作业日志概览
--   ('flink_job_log_overview', 'Flink作业日志概览', 'flink',
--    '统计Flink作业的错误日志和警告日志',
--    '{
--      "type": "object",
--      "properties": {
--        "time_start": {"type": "string", "format": "date-time", "title": "开始时间"},
--        "time_end": {"type": "string", "format": "date-time", "title": "结束时间"},
--        "log_level": {"type": "string", "enum": ["ERROR", "WARN", "INFO"], "title": "日志级别", "default": "ERROR"}
--      },
--      "required": ["time_start", "time_end"]
--    }',
--    '{"time_start": "2024-01-01 00:00:00", "time_end": "2024-01-02 00:00:00", "log_level": "ERROR"}',
--    '["html", "excel"]', 1, 1),
-- 
--   -- 4. StarRocks错误日志概览
--   ('starrocks_error_overview', 'StarRocks错误日志概览', 'starrocks',
--    '统计StarRocks的错误日志',
--    '{
--      "type": "object",
--      "properties": {
--        "time_start": {"type": "string", "format": "date-time", "title": "开始时间"},
--        "time_end": {"type": "string", "format": "date-time", "title": "结束时间"},
--        "instance_ids": {"type": "array", "items": {"type": "integer"}, "title": "集群实例"}
--      },
--      "required": ["time_start", "time_end"]
--    }',
--    '{"time_start": "2024-01-01 00:00:00", "time_end": "2024-01-02 00:00:00", "instance_ids": []}',
--    '["html", "excel"]', 1, 1),
-- 
--   -- 5. StarRocks慢查询报表
--   ('starrocks_query_slow', 'StarRocks慢查询报表', 'starrocks',
--    '统计StarRocks的慢查询',
--    '{
--      "type": "object",
--      "properties": {
--        "time_start": {"type": "string", "format": "date-time", "title": "开始时间"},
--        "time_end": {"type": "string", "format": "date-time", "title": "结束时间"},
--        "instance_ids": {"type": "array", "items": {"type": "integer"}, "title": "集群实例"},
--        "duration_threshold": {"type": "integer", "title": "耗时阈值(毫秒)", "default": 10000, "description": "查询耗时超过此值才被认为是慢查询"}
--      },
--      "required": ["time_start", "time_end"]
--    }',
--    '{"time_start": "2024-01-01 00:00:00", "time_end": "2024-01-02 00:00:00", "instance_ids": [], "duration_threshold": 10000}',
--    '["html", "excel"]', 1, 1),
-- 
--   -- 6. 告警概览报表
--   ('alerts_overview', '告警概览报表', 'alerts',
--    '统计Flink集群的告警情况',
--    '{
--      "type": "object",
--      "properties": {
--        "time_start": {"type": "string", "format": "date-time", "title": "开始时间"},
--        "time_end": {"type": "string", "format": "date-time", "title": "结束时间"},
--        "alert_type": {"type": "string", "title": "告警类型", "description": "留空表示全部类型"}
--      },
--      "required": ["time_start", "time_end"]
--    }',
--    '{"time_start": "2024-01-01 00:00:00", "time_end": "2024-01-02 00:00:00", "alert_type": ""}',
--    '["html", "excel"]', 1, 1);
-- COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
